package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.annotation.AutoFill;
import com.sky.dto.SetmealPageQueryDTO;
import com.sky.entity.Setmeal;
import com.sky.enumeration.OperationType;
import com.sky.vo.DishItemVO;
import com.sky.vo.SetmealVO;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

@Mapper
public interface SetmealMapper {
    @Select("select count(id) from setmeal where category_id=#{id}")
    Integer countByCategoryId(Long id);
    @AutoFill(OperationType.INSERT)

    void insert(Setmeal setmeal);

    Page<SetmealVO> page(SetmealPageQueryDTO setmealPageQueryDTO);
    @AutoFill(OperationType.UPDATE)
    void update(Integer status, Long id);

    void update(Setmeal setmeal);

    SetmealVO getById(Long id);

    void deletByIds(List<Long> ids);
    @Select("select * from setmeal where category_id=#{categoryId}")
    List<Setmeal> getByCategoryId(Long categoryId);
    @Select("select s.copies,d.description,d.image,d.name  from setmeal_dish s left join dish d on s.dish_id = d.id where s.setmeal_id=#{id}")
    List<DishItemVO> getDishesBySetmealId(Long id);

    Integer countByMap(Map map);
}
